﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AdaptiveDeNet.Functions
{
    public class CEC14Suite
    {
        private double[] lowerBound;
        private double[] upperBound;
        private double myEpps;
        private int funcNum;
        private int maxEvals;
        private int n;
        private int dim;
        private Queue<double> fESmultipliers;
        private Function function;

        public CEC14Suite(int funcNum, int dim = 30)
        {
            this.funcNum = funcNum;

            lowerBound = new double[dim];
            upperBound = new double[dim];

            for (int i = 0; i < lowerBound.Length; i++)
            {
                lowerBound[i] = -100;
            }

            for (int i = 0; i < upperBound.Length; i++)
            {
                upperBound[i] = 100;
            }

            myEpps = 10E-8;
            maxEvals = 300000;
            n = 50;
            this.dim = dim;

            fESmultipliers = new Queue<double>();

            fESmultipliers.Enqueue(0.01);
            fESmultipliers.Enqueue(0.02);
            fESmultipliers.Enqueue(0.03);
            fESmultipliers.Enqueue(0.05);
            fESmultipliers.Enqueue(0.1);
            fESmultipliers.Enqueue(0.2);
            fESmultipliers.Enqueue(0.3);
            fESmultipliers.Enqueue(0.4);
            fESmultipliers.Enqueue(0.5);
            fESmultipliers.Enqueue(0.6);
            fESmultipliers.Enqueue(0.7);
            fESmultipliers.Enqueue(0.8);
            fESmultipliers.Enqueue(0.9);
            fESmultipliers.Enqueue(1.0);

            function = new Functions.CEC14FuncImpl(funcNum, dim);

            //function = new Ackley(upperBound, lowerBound);
        }

        public Function Function
        {
            get { return function; }
            set { function = value; }
        }

        public Queue<double> FESmultipliers
        {
            get { return fESmultipliers; }
            set { fESmultipliers = value; }
        }

        public int Dim
        {
            get { return dim; }
            set { dim = value; }
        }

        public int N
        {
            get { return n; }
            set { n = value; }
        }

        public int MaxEvals
        {
            get { return maxEvals; }
            set { maxEvals = value; }
        }

        public int FuncNum
        {
            get { return funcNum; }
            set { funcNum = value; }
        }

        public double MyEpps
        {
            get { return myEpps; }
            set { myEpps = value; }
        }

        public double[] UpperBound
        {
            get { return upperBound; }
            set { upperBound = value; }
        }

        public double[] LowerBound
        {
            get { return lowerBound; }
            set { lowerBound = value; }
        }

        public void QueueRenew()
        {
            if (fESmultipliers.Count < 14)
            {
                fESmultipliers.Clear();

                fESmultipliers.Enqueue(0.01);
                fESmultipliers.Enqueue(0.02);
                fESmultipliers.Enqueue(0.03);
                fESmultipliers.Enqueue(0.05);
                fESmultipliers.Enqueue(0.1);
                fESmultipliers.Enqueue(0.2);
                fESmultipliers.Enqueue(0.3);
                fESmultipliers.Enqueue(0.4);
                fESmultipliers.Enqueue(0.5);
                fESmultipliers.Enqueue(0.6);
                fESmultipliers.Enqueue(0.7);
                fESmultipliers.Enqueue(0.8);
                fESmultipliers.Enqueue(0.9);
                fESmultipliers.Enqueue(1.0);
            }

        }


    }
}
